package Panel;

//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//


import Utils.getTime;

import java.awt.*;
import java.awt.event.MouseEvent;
import java.util.Calendar;
import java.util.Timer;
import javax.swing.*;

public class ClockPanel extends JPanel{
    private static JLabel time;

    public ClockPanel() {
        this.setLayout(null);
        this.setBounds(0,0,220,220);
        this.setOpaque(false);
        time = new JLabel();
        time.setBounds(50,70,180,50);
        this.add(time);
        run();
    }
    private void drawClock() {
        time.setText(getTime.getDateTime());
    }

    public void run() {
        Runnable runnable = new Runnable() {
            public void run() {
                while (true) {
                    // ------- 要运行的任务代码
                    drawClock();
                    try {
                        // sleep()：同步延迟数据，并且会阻塞线程
                        Thread.sleep(100L);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        };
        //创建定时器
        Thread thread = new Thread(runnable);
        //开始执行
        thread.start();

    }



}
